from PySide6.QtCore import Qt

# QHBoxLayout 水平盒子布局
# QVBoxLayout 垂直盒子布局

from PySide6.QtWidgets import QApplication, QWidget, QPushButton, QHBoxLayout, QVBoxLayout

class RocWidget(QWidget):
    def __init__(self) -> None:
        super().__init__()
        self.setWindowTitle('窗口标题')

        btn1 = QPushButton('按键1')
        btn1.clicked.connect(self.btn1_click)
        btn2 = QPushButton('按键2')
        btn2.clicked.connect(self.btn2_click)

        # 定义布局，并为布局添加组件
        # btn_layout = QHBoxLayout()
        btn_layout = QVBoxLayout()
        btn_layout.addWidget(btn1)
        btn_layout.addWidget(btn2)

        self.setLayout(btn_layout)

    def btn1_click(self):
        print('btn1 clicked~')

    def btn2_click(self):
        print('btn2 clicked~')

app = QApplication()
widget = RocWidget()

widget.show()
app.exec()